(function () {
    var canvas = this.__canvas = new fabric.Canvas('c1');
    fabric.Object.prototype.transparentCorners = false;
    canvas.on('mouse:over', function (e) {
        if (e.target) {
            e.target.set('fill', 'red');
            canvas.renderAll();
        }
    });
    canvas.on('mouse:out', function (e) {
        if (e.target) {
            e.target.set('fill', 'green');
            canvas.renderAll();
        }
    });
    //分布
    for (var i = 15; i--;) {
        var dim = fabric.util.getRandomInt(30, 60);
        var klass = ['Rect', 'Triangle', 'Circle']
        [fabric.util.getRandomInt(0, 2)];
        var options = {
            top: fabric.util.getRandomInt(0, 400),
            left: fabric.util.getRandomInt(0, 400),
            fill: 'green'
        };
        if (klass === 'Circle') {
            options.radius = dim;
        } else {
            options.width = dim;
            options.height = dim;
        }
        canvas.add(new fabric[klass](options));
    }
})();